package com.zhang.common.core.vo;

import com.zhang.common.core.constant.ResultConstant;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.io.Serializable;

/**
 * 统一返回对象
 * @param <T>
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class Result<T>  implements Serializable {
    int code;
    String message;
    T data;

    public static <T> Result<T> success(T data){
       return new Result<T> (ResultConstant.RESULT_SUCCES,"成功",data);
    }

    public static Result success(){
        return success(null);
    }



    public Result(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public static void main(String[] args) {

    }
}
